package com.ptswitch.material.util;

import org.hxzon.project.HibernateDao;

import com.ptswitch.material.model.common.EMailAddress;
import com.ptswitch.material.model.common.HLog;
import com.ptswitch.material.model.common.Uzer;
import com.ptswitch.material.model.contract.Contract;
import com.ptswitch.material.model.contract.ContractInvoice;
import com.ptswitch.material.model.contract.ContractPayment;
import com.ptswitch.material.model.material.Bom;
import com.ptswitch.material.model.material.BomMaterial;
import com.ptswitch.material.model.material.Material;
import com.ptswitch.material.model.security.Permission;
import com.ptswitch.material.model.security.Role;

public class DaoEx extends HibernateDao {
    protected String getDefaultOrderByString(Class<?> clazz) {
        if (clazz == Material.class || clazz == BomMaterial.class) {
            return " order by p.code asc";
        } else if (clazz == Bom.class) {
            return " order by p.code asc,p.version desc";
        } else if (clazz == Contract.class) {
            return " order by p.code desc";
        } else if (clazz == ContractInvoice.class || clazz == ContractPayment.class || clazz == HLog.class) {
            return " order by p.createTime desc";
        } else if (clazz == Uzer.class) {
            return " order by p.username";
        } else if (clazz == EMailAddress.class) {
            return " order by p.realname desc";
        } else if (clazz == Permission.class) {
            return " order by p.permissionName asc";
        } else if (clazz == Role.class) {
            return " order by p.roleGroup asc,p.roleName asc";
        }
        return "";
    }
}
